package com.example.demo.util;

import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class RandomizeKeywords {
    public static void main(String[] args) {
        String inputFile = "D:\\打乱后的关键词.txt";
        String outputFile = "D:\\A.txt";

        List<String> lines = new ArrayList<>();

        try (BufferedReader reader = new BufferedReader(new FileReader(inputFile))) {
            String line;
            while ((line = reader.readLine()) != null) {
                lines.add(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

        Collections.shuffle(lines);

        try (BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile))) {
            for (String line : lines) {
                writer.write(line);
                writer.newLine();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

        System.out.println("文件内容已重新随机打乱并导出到A.txt文件中。");
    }
}